ExtremosCondicionados(2)
system:sage


<CENTER>
<HR>
<H3>Extremos condicionados de funcións de dúas ou tres variables con unha ou dúas condicións</H3>
</CENTER>

{{{id=1|
#auto
%hide
html('<applet code="LagrangeMultipliersTwoVariables" archive="http://ocw.mit.edu/ans7870/18/18.02/f07/tools/lagrangeMultipliersTwoVariables.jar, http://ocw.mit.edu/ans7870/18/18.02/f07/tools/mk_lib.jar, http://ocw.mit.edu/ans7870/18/18.02/f07/tools/parser_math.jar, http://ocw.mit.edu/ans7870/18/18.02/f07/tools/jcbwt363.jar" width=840 height=550></applet>')
var('x,y,z,l,m')
@interact
def a(funcion =input_box(default=x*y^2), condiciones=input_box(default=[x^2+y^2-10])):
    cond=False
    if len(condiciones)==2:
        if z in condiciones[1].variables():
            cond=True
    if z in funcion.variables() or z in condiciones[0].variables() or cond:
        if len(condiciones)==2:
            L=funcion+l*condiciones[0]+m*condiciones[1]
            sol=solve([diff(L,x)==0,diff(L,y)==0,diff(L,z)==0,diff(L,l)==0,diff(L,m)==0],[x,y,z,l,m])
        if len(condiciones)==1:
            L=funcion+l*condiciones[0]
            sol=solve([diff(L,x)==0,diff(L,y)==0,diff(L,z)==0,diff(L,l)==0],[x,y,z,l])
    else:
        if len(condiciones)==2:
            L=funcion+l*condiciones[0]+m*condiciones[1]
            sol=solve([diff(L,x)==0,diff(L,y)==0,diff(L,l)==0,diff(L,m)==0],[x,y,l,m])
        if len(condiciones)==1:
            L=funcion+l*condiciones[0]
            sol=solve([diff(L,x)==0,diff(L,y)==0,diff(L,l)==0],[x,y,l])
    for i in range(len(sol)):
        if z in funcion.variables()or z in condiciones[0].variables() or cond:
            show(sol[i][0:3])
        else:
            show(sol[i][0:2])
///
<html><font color='black'><applet code="LagrangeMultipliersTwoVariables" archive="http://ocw.mit.edu/ans7870/18/18.02/f07/tools/lagrangeMultipliersTwoVariables.jar, http://ocw.mit.edu/ans7870/18/18.02/f07/tools/mk_lib.jar, http://ocw.mit.edu/ans7870/18/18.02/f07/tools/parser_math.jar, http://ocw.mit.edu/ans7870/18/18.02/f07/tools/jcbwt363.jar" width=840 height=550></applet></font></html>
<html><!--notruncate--><div padding=6 id="div-interact-1"> <table width=800px height=20px bgcolor="#c5c5c5"
                 cellpadding=15><tr><td bgcolor="#f9f9f9" valign=top align=left><table><tr><td align=right><font color="black">funcion&nbsp;</font></td><td><input type="text" value="x*y^2" size=80 onchange="interact(1, '_interact_.update(\'1\', \'funcion\', 1, _interact_.standard_b64decode(\''+encode64(this.value)+'\'), globals()); _interact_.recompute(\'1\');')"></input></td></tr>
<tr><td align=right><font color="black">condiciones&nbsp;</font></td><td><input type="text" value="[x^2 + y^2 - 10]" size=80 onchange="interact(1, '_interact_.update(\'1\', \'condiciones\', 2, _interact_.standard_b64decode(\''+encode64(this.value)+'\'), globals()); _interact_.recompute(\'1\');')"></input></td></tr>
</table><div id="cell-interact-1"><?__SAGE__START>
        <table border=0 bgcolor="white" width=100% height=100%>
        <tr><td bgcolor="white" align=left valign=top><pre><?__SAGE__TEXT></pre></td></tr>
        <tr><td  align=left valign=top><?__SAGE__HTML></td></tr>
        </table><?__SAGE__END></div></td>
                 </tr></table></div>
                 </html>
}}}

{{{id=2|

///
}}}